<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>考勤设置</title>
    <link rel="stylesheet" type="text/css" href="../lib/pagination/style/pagination.css"/>
    <link rel="stylesheet" type="text/css" href="../css/base.css"/>
    <link rel="stylesheet" type="text/css" href="../css/attend/laydate.css"/>
    <script type="text/javascript" src="../js/common/language.js" ></script>
    <script type="text/javascript" src="../js/news/jquery-1.9.1.js"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
    <script src="../lib/laydate/laydate.js"></script>
    <script src="../js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="/js/ajaxupload.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jquery.form.min.js"></script>
    <script src="../lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../lib/layer/layer.js?20201106"></script>
    <script src="../js/jquery/jquery.cookie.js"></script>
    <script src="../js/leader/WdatePicker.js"></script>

    <style>
        a{
            text-decoration: none;
            color: #207bd6;
        }
        .buttonDiv{
            width: 100%;
        }
        .buttonDiv>div{
            float: left;
            margin: 20px 10px;
        }
        .buttonDiv .deleteBtn{
            width: 99px;
            height: 28px;
            /*margin: 20px auto;*/
            background: url("../img/btn_deletecontent_03.png") no-repeat;
            line-height: 28px;
            cursor: pointer;
        }
        .buttonDiv .exportDiv{
            width: 99px;
            height: 28px;
            /*margin: 20px auto;*/
            background: url("../img/icon_daoru.png") no-repeat;
            line-height: 28px;
            cursor: pointer;
        }
        .fileDone select{
            width: 160px;
            height:28px;
        }
        #tr_td tr:nth-child(odd){
            background-color: #fff;
        }

        input{
            float: none;
        }
        .newMange input[type="text"]{
            width: 260px;
            height: 30px;
        }
        select{
            width: 260px;
            height: 30px;
        }
        textarea{
            width: 260px;
            height: 50px;
            vertical-align: middle;
        }
        a{
            text-decoration: none;
            color: #207bd6;
        }
        .newTbale tr td{
            border-right: #ccc 1px solid;
            padding: 5px;
        }
        .divBtn{
            float: right;
            width: 120px;
            height: 28px;
            background: #2b7fe0;
            color: #fff;
            font-size: 14px;
            line-height: 28px;
            margin-right: 4%;
            margin-top: 20px;
            cursor: pointer;
            border-radius: 4px;
        }
        .divTable{
            width: 90%;
            margin: 0px auto;
        }
        .divTable table{
            width: 100%;
        }
        .divTable table tr th{
            padding: 8px;
            font-size: 13pt;
            color: #2F5C8F;
        }
        td{
            font-size: 11pt;
        }
        .divTable table tr td{
            text-align: center;
        }
        .newPage{
            width: 80%;
            margin: 0 auto;
        }
        .newPage table{
            width: 100%;
        }
        .newPage table tr td{
            text-align: left;
        }
        .newPage table tr td input[type="text"]{
            width: 200px;
            height: 30px;
            border-radius: 4px;
            font-size: 11pt;
            padding-left: 5px;
        }
        .newPage table tr td input[type="radio"]{
            width: 16px;
            margin: -1px;
        }
        .newPage table tr td input[type="checkbox"]{
            width: 16px;
            margin: -1px;
        }
        .qiandao{
            /*font-size: 11pt;*/
            font-size: 13pt;
            font-weight: bold;
        }
        .btnBox{
            width: 100%;
            margin-bottom: 20px;
        }
        .btnBox .btn{
            width: 100px;
            height: 30px;
            margin: 0 auto;
        }
        .btnBox .btn div{
            float: left;
            width: 40px;
            height: 28px;
            background: #2b7fe0;
            border-radius: 4px;
            cursor: pointer;
            text-align: center;
            color: #ffffff;
            line-height: 28px;
        }
        .saveBtn{
            margin-right: 10px;
        }

        .return{
            width: 103px;
            float: right;
            height: 28px;
            background: #2b7fe0;
            border-radius: 4px;
            cursor: pointer;
            text-align: center;
            color: #ffffff;
            line-height: 28px;
            font-size: 14px;
            margin: 20px 70px 0 0;
        }
        .return a{
            color: #ffffff;
            padding:0 30px;
        }
        .layui-layer{
            top:200px;
        }
        .publishtip {
            overflow: hidden;
            text-overflow:ellipsis;
            width: 100%;
            white-space:nowrap;
        }

    </style>
</head>

<body>
<div class="bx">

    <%--头部按钮--%>
    <div class="navigation  clearfix juMange" id="atSet" style="display: block;">
        <div class="left" style="margin-left: 30px">
            <img src="/img/commonTheme/${sessionScope.InterfaceModel}/icon_manageFile.png">
            <div class="news">考勤类型设置</div>
        </div>


        <div class="return"><a href="/attendanceWay/attindex">返回</a></div>

        <div class="divBtn">
            <img src="../../img/mywork/newbuildworjk.png" alt="" style="margin-left: 6px;margin-top: -4px;">
            <span style="font-size: 11pt;">新建考勤类型</span>
        </div>
    </div>

    <%--列表--%>
    <div class="divTable" style="display: block;">
        <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse">
            <thead>
            <tr>
                <th>类型名称</th>
                <%--<th>第一次签到时间</th>--%>
                <%--<th>第二次签到时间</th>--%>
                <%--<th>第三次签到时间</th>--%>
                <%--<th>第四次签到时间</th>--%>
                <%--<th>第五次签到时间</th>--%>
                <%--<th>第六次签到时间</th>--%>
                <th>签到类型</th>
                <th>是否开启位置限制</th>
                <th>是否开启IP限制</th>
                <th>是否开启WiFi</th>
                <th>是否开启外勤</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody id="trList">

            </tbody>

        </table>
        <%--<div class="right">--%>
            <%--<!-- 分页按钮-->--%>
            <%--<div class="M-box3" id="dbgz_page"></div>--%>
        <%--</div>--%>
    </div>

    <%--表单--%>
    <div class="newPage" style="display: none;">


        <form id="form1" action="/attendSet/newAttendSet">

            <%--选择签到方式--%>
            <table name="leixing" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse">

                <tr>
                    <td style="width: 80px;"><span style="color: red">*</span>类型名称：</td>
                    <td colspan="5"><input type="text" name="title"></td>
                </tr>
                <%--单选--%>
                <tr>
                    <td style="width: 80px;"><span style="color: red">*</span>签到类型：</td>
                    <td colspan="5">
                        <input type="radio" name="attendType" value="0" checked> 固定签到
                        <input type="radio" name="attendType" value="1" style="margin-left: 30px;"> 弹性工时
                    </td>
                </tr>
            </table>

            <%--固定签到方式--%>


            <%--弹性签到方式--%>



            <%--上下班签到设置--%>
            <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse;margin-bottom: 20px;">
                <tr style="border-top: none;">
                    <td colspan="3" style="text-align: center;"><span class="qiandao">上下班签到设置</span></td>
                </tr>
                <tr class="officeHours">
                    <td style="width: 180px;">允许上班提前签到时间：</td>
                    <td colspan="2"><input type="text" name="worktimeF" class="time_7" onclick="WdatePicker({onpicked:function(dq){init();},dateFmt:'HH:mm:ss'})" readonly></td>
                </tr>
                <tr class="officeHours">
                    <td style="width: 180px;">允许上班延后签到时间：</td>
                    <td colspan="2"><input type="text" name="worktimeB" class="time_8" onclick="WdatePicker({onpicked:function(dq){init();},dateFmt:'HH:mm:ss'})" readonly></td>
                </tr>
                <tr class="officeHours">
                    <td style="width: 180px;">允许下班提前签到时间：</td>
                    <td colspan="2"><input type="text" name="workafterF" class="time_9" onclick="WdatePicker({onpicked:function(dq){init();},dateFmt:'HH:mm:ss'})" readonly></td>
                </tr>
                <tr class="officeHours">
                    <td style="width: 180px;">允许下班延后签到时间：</td>
                    <td colspan="2"><input type="text" name="workafterB" class="time_10" onclick="WdatePicker({onpicked:function(dq){init();},dateFmt:'HH:mm:ss'})" readonly></td>
                </tr>
                <tr>
                    <td>位置：</td>
                    <td>
                        <label for="">
                            <input type="radio" name="locationOn" value="1">
                            <span style="margin-right: 13px;">开启</span>
                        </label>
                        <label for="">
                            <input type="radio" name="locationOn" value="0" checked>
                            <span>关闭</span>
                        </label>
                    </td>
<%--                    <td><input type="text" name="location" id="inLocation"></td>--%>
                    <td>
                        <label style="width: 47%;position:relative">
                            <input type="text" name="gridLocation" style="width:200px" readonly="readonly">
                            <button type="button" class="dwbtn" style="position: absolute;width: 66px;height: 30px; background-color: #228cdc;color: #fff; right: 0px;top:-4px;border-radius: 3px;cursor: pointer;">点击定位</button>
                        </label>
                    </td>
                </tr>
                <tr>
                    <td>范围：</td>
                    <td colspan="2">
                        <select name="ranges" id="ranges" style="width: 100px;">
                            <option value="0">0</option>
                            <option value="10">10</option>
                            <option value="20">20</option>
                            <option value="30">30</option>
                            <option value="40">40</option>
                            <option value="50">50</option>
                            <option value="100">100</option>
                            <option value="200">200</option>
                            <option value="300">300</option>
                            <option value="400">400</option>
                            <option value="500">500</option>
                            <option value="600">600</option>
                            <option value="700">700</option>
                            <option value="800">800</option>
                            <option value="900">900</option>
                            <option value="1000">1000</option>
                        </select>
                    </td>
                </tr>
                <tr><td colspan="3" style="text-align: center;"><span class="qiandao">WIFI签到设置</span></td></tr>
                <tr>
                    <td>是否开启WiFi签到：</td>
                    <td>
                        <label for="">
                            <input type="radio" name="wifiOn" value="1">
                            <span style="margin-right: 13px;">开启</span>
                        </label>
                        <label for="">
                            <input type="radio" name="wifiOn" value="0" checked>
                            <span>关闭</span>
                        </label>
                    </td>
                    <td colspan=""><span>启用Wi-Fi签到后，则不会限制考勤地点和范围</span></td>
                </tr>

                <tr>
                    <td>是否开启IP限制：</td>
                    <td>
                        <label for="">
                            <input type="radio" name="ipOn" value="1">
                            <span style="margin-right: 13px;">开启</span>
                        </label>
                        <label for="">
                            <input type="radio" name="ipOn" value="0" checked>
                            <span>关闭</span>
                        </label>
                    </td>
                </tr>

                <tr name="wifiOnName" style="display:none;">
                    <td>IP段：</td>
                    <td colspan="2">
                        <input type="text" id="ipParagraph1" class="time_10" onkeyup="value=value.replace(/[^0-9.]/g,'')" maxlength="15">——
                        <input type="text" id="ipParagraph2" class="time_10" onkeyup="value=value.replace(/[^0-9.]/g,'')" maxlength="15">
                    </td>
                </tr>


                <tr><td colspan="3" style="text-align: center;"><span class="qiandao">外勤签到设置</span></td></tr>
                <tr>
                    <td>是否开启外勤：</td>
                    <td colspan="2">
                        <label for="">
                            <input type="radio" name="isOut" value="1">
                            <span style="margin-right: 13px;">是</span>
                        </label>
                        <label for="">
                            <input type="radio" name="isOut" value="0" checked>
                            <span>否</span>
                        </label>
                    </td>
                </tr>
                <tr><td colspan="3" style="text-align: center;"><span class="qiandao">其它考勤设置</span></td></tr>
                <tr>
                    <td>是否开启加班：</td>
                    <td colspan="2">
                        <label for="">
                            <input type="radio" name="isOvertime" value="1" checked>
                            <span style="margin-right: 13px;">是</span>
                        </label>
                        <label for="">
                            <input type="radio" name="isOvertime" value="0" >
                            <span>否</span>
                        </label>
                    </td>
                </tr>
                <tr>
                    <td>是否开启值班：</td>
                    <td colspan="2">
                        <label for="">
                            <input type="radio" name="isDuty" value="1" checked>
                            <span style="margin-right: 13px;">是</span>
                        </label>
                        <label for="">
                            <input type="radio" name="isDuty" value="0">
                            <span>否</span>
                        </label>
                    </td>
                </tr>
                <tr>
                    <td>是否开启出差：</td>
                    <td colspan="2">
                        <label for="">
                            <input type="radio" name="isTrip" value="1" checked>
                            <span style="margin-right: 13px;">是</span>
                        </label>
                        <label for="">
                            <input type="radio" name="isTrip" value="0">
                            <span>否</span>
                        </label>
                    </td>
                </tr>
                <tr>
                    <td>是否开启请假：</td>
                    <td colspan="2">
                        <label for="">
                            <input type="radio" name="isLeave" value="1" checked>
                            <span style="margin-right: 13px;">是</span>
                        </label>
                        <label for="">
                            <input type="radio" name="isLeave" value="0">
                            <span>否</span>
                        </label>
                    </td>
                </tr>
                <tr>
                    <td>是否开启外出：</td>
                    <td colspan="2">
                        <label for="">
                            <input type="radio" name="isGo" value="1" checked>
                            <span style="margin-right: 13px;">是</span>
                        </label>
                        <label for="">
                            <input type="radio" name="isGo" value="0">
                            <span>否</span>
                        </label>
                    </td>
                </tr>
                <tr><td colspan="3" style="text-align: center;"><span class="qiandao">考勤日期设置</span></td></tr>
                <tr>
                    <td>考勤日期：</td>
                    <td colspan="2">
                        <span style="margin-left: 15px;">星期一</span>
                        <input type="checkbox" class="workDay" value="1">
                        <span style="margin-left: 15px;">星期二</span>
                        <input type="checkbox" class="workDay" value="2">
                        <span style="margin-left: 15px;">星期三</span>
                        <input type="checkbox" class="workDay" value="3">
                        <span style="margin-left: 15px;">星期四</span>
                        <input type="checkbox" class="workDay" value="4">
                        <span style="margin-left: 15px;">星期五</span>
                        <input type="checkbox" class="workDay" value="5">
                        <span style="margin-left: 15px;">星期六</span>
                        <input type="checkbox" class="workDay" value="6">
                        <span style="margin-left: 15px;">星期日</span>
                        <input type="checkbox" class="workDay" value="7">
                    </td>
                </tr>
            </table>
        </form>
        <div class="btnBox">
            <div class="btn">
                <div class="saveBtn" btnType="">保存</div>
                <div class="backBtn">返回</div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">

    //固定签到
    var fixed='<table name="fixed" border="0" cellpadding="0" cellspacing="0" style=" border-collapse: collapse">\n' +
        '                <tr>\n' +
        '                    <td colspan="6" style="text-align: center;"><span class="qiandao"><span style="color: red">*</span>第一次签到</span></td>\n' +
        '                </tr>\n' +
        '                <tr>\n' +
        '                    <td style="width: 80px;">是否开启：</td>\n' +
        '                    <td>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="atime1Setother" value="1">\n' +
        '                            <span style="margin-right: 13px;">是</span>\n' +
        '                        </label>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="atime1Setother" value="0" checked>\n' +
        '                            <span>否</span>\n' +
        '                        </label>\n' +
        '                    </td>\n' +
        '                    <td style="width: 60px;">类型：</td>\n' +
        '                    <td>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="commute1" value="1" checked>\n' +
        '                            <span style="margin-right: 13px;">上班</span>\n' +
        '                        </label>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="commute1" value="2">\n' +
        '                            <span>下班</span>\n' +
        '                        </label>\n' +
        '                    </td>\n' +
        '                    <td style="width: 60px;">时间：</td>\n' +
        '                    <td><input type="text" name="atime1" class="time_1"  onclick="WdatePicker({onpicked:function(dq){init();},dateFmt:\'HH:mm:ss\'})" readonly></td>\n' +
        '                </tr>\n' +
        '                <tr>\n' +
        '                    <td colspan="6" style="text-align: center;"><span class="qiandao">第二次签到</span></td>\n' +
        '                </tr>\n' +
        '                <tr>\n' +
        '                    <td style="width: 80px;">是否开启：</td>\n' +
        '                    <td>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="atime2Setother" value="1">\n' +
        '                            <span style="margin-right: 13px;">是</span>\n' +
        '                        </label>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="atime2Setother" value="0" checked>\n' +
        '                            <span>否</span>\n' +
        '                        </label>\n' +
        '                    </td>\n' +
        '                    <td style="width: 60px;">类型：</td>\n' +
        '                    <td>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="commute2" value="1" checked>\n' +
        '                            <span style="margin-right: 13px;">上班</span>\n' +
        '                        </label>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="commute2" value="2">\n' +
        '                            <span>下班</span>\n' +
        '                        </label>\n' +
        '                    </td>\n' +
        '                    <td style="width: 60px;">时间：</td>\n' +
        '                    <td><input type="text" name="atime2" class="time_2" onclick="WdatePicker({onpicked:function(dq){init();},dateFmt:\'HH:mm:ss\'})" readonly></td>\n' +
        '                </tr>\n' +
        '                <tr>\n' +
        '                    <td colspan="6" style="text-align: center;"><span class="qiandao">第三次签到</span></td>\n' +
        '                </tr>\n' +
        '                <tr>\n' +
        '                    <td style="width: 80px;">是否开启：</td>\n' +
        '                    <td>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="atime3Setother" value="1">\n' +
        '                            <span style="margin-right: 13px;">是</span>\n' +
        '                        </label>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="atime3Setother" value="0" checked>\n' +
        '                            <span>否</span>\n' +
        '                        </label>\n' +
        '                    </td>\n' +
        '                    <td style="width: 60px;">类型：</td>\n' +
        '                    <td>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="commute3" value="1" checked>\n' +
        '                            <span style="margin-right: 13px;">上班</span>\n' +
        '                        </label>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="commute3" value="2">\n' +
        '                            <span>下班</span>\n' +
        '                        </label>\n' +
        '                    </td>\n' +
        '                    <td style="width: 60px;">时间：</td>\n' +
        '                    <td><input type="text" name="atime3" class="time_3" onclick="WdatePicker({onpicked:function(dq){init();},dateFmt:\'HH:mm:ss\'})" readonly></td>\n' +
        '                </tr>\n' +
        '                <tr>\n' +
        '                    <td colspan="6" style="text-align: center;"><span class="qiandao">第四次签到</span></td>\n' +
        '                </tr>\n' +
        '                <tr>\n' +
        '                    <td style="width: 80px;">是否开启：</td>\n' +
        '                    <td>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="atime4Setother" value="1">\n' +
        '                            <span style="margin-right: 13px;">是</span>\n' +
        '                        </label>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="atime4Setother" value="0" checked>\n' +
        '                            <span>否</span>\n' +
        '                        </label>\n' +
        '                    </td>\n' +
        '                    <td style="width: 60px;">类型：</td>\n' +
        '                    <td>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="commute4" value="1" checked>\n' +
        '                            <span style="margin-right: 13px;">上班</span>\n' +
        '                        </label>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="commute4" value="2">\n' +
        '                            <span>下班</span>\n' +
        '                        </label>\n' +
        '                    </td>\n' +
        '                    <td style="width: 60px;">时间：</td>\n' +
        '                    <td><input type="text" name="atime4" class="time_4" onclick="WdatePicker({onpicked:function(dq){init();},dateFmt:\'HH:mm:ss\'})" readonly></td>\n' +
        '                </tr>\n' +
        '                <tr>\n' +
        '                    <td colspan="6" style="text-align: center;"><span class="qiandao">第五次签到</span></td>\n' +
        '                </tr>\n' +
        '                <tr>\n' +
        '                    <td style="width: 80px;">是否开启：</td>\n' +
        '                    <td>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="atime5Setother" value="1">\n' +
        '                            <span style="margin-right: 13px;">是</span>\n' +
        '                        </label>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="atime5Setother" value="0" checked>\n' +
        '                            <span>否</span>\n' +
        '                        </label>\n' +
        '                    </td>\n' +
        '                    <td style="width: 60px;">类型：</td>\n' +
        '                    <td>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="commute5" value="1" checked>\n' +
        '                            <span style="margin-right: 13px;">上班</span>\n' +
        '                        </label>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="commute5" value="2">\n' +
        '                            <span>下班</span>\n' +
        '                        </label>\n' +
        '                    </td>\n' +
        '                    <td style="width: 60px;">时间：</td>\n' +
        '                    <td><input type="text" name="atime5" class="time_5" onclick="WdatePicker({onpicked:function(dq){init();},dateFmt:\'HH:mm:ss\'})" readonly></td>\n' +
        '                </tr>\n' +
        '                <tr>\n' +
        '                    <td colspan="6" style="text-align: center;"><span class="qiandao">第六次签到</span></td>\n' +
        '                </tr>\n' +
        '                <tr>\n' +
        '                    <td style="width: 80px;">是否开启：</td>\n' +
        '                    <td>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="atime6Setother" value="1">\n' +
        '                            <span style="margin-right: 13px;">是</span>\n' +
        '                        </label>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="atime6Setother" value="0" checked>\n' +
        '                            <span>否</span>\n' +
        '                        </label>\n' +
        '                    </td>\n' +
        '                    <td style="width: 60px;">类型：</td>\n' +
        '                    <td>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="commute6" value="1" checked>\n' +
        '                            <span style="margin-right: 13px;">上班</span>\n' +
        '                        </label>\n' +
        '                        <label for="">\n' +
        '                            <input type="radio" name="commute6" value="2">\n' +
        '                            <span>下班</span>\n' +
        '                        </label>\n' +
        '                    </td>\n' +
        '                    <td style="width: 60px;">时间：</td>\n' +
        '                    <td><input type="text" name="atime6" class="time_6" onclick="WdatePicker({onpicked:function(dq){init();},dateFmt:\'HH:mm:ss\'})" readonly></td>\n' +
        '                </tr>\n' +
        '            </table>';


    //弹性工时
    var elasticity='<table name="workStart" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse">\n' +
        '                <tr>\n' +
        '                    <td colspan="6" style="text-align: center;"><span class="qiandao"><span style="color: red">*</span>弹性工作设置（24小时制）</span></td>\n' +
        '                </tr>\n' +
        '                <tr>\n' +
        '                    <td style="width: 80px;">开始时间：</td>\n' +
        '                    <td><input type="text" name="workStart" class="time_1"  onclick="WdatePicker({onpicked:function(dq){init();},dateFmt:\'HH:mm:ss\'})" readonly></td>\n' +
        '\n' +
        '\n' +
        '                    <td style="width: 80px;">结束时间：</td>\n' +
        '                    <td><input type="text" name="workEnd" class="time_1"  onclick="WdatePicker({onpicked:function(dq){init();},dateFmt:\'HH:mm:ss\'})" readonly></td>\n' +
        '\n' +
        '\n' +
        '                    <td style="width: 110px;">最小工作小时：</td>\n' +
        '                    <td><input class="time_1" name="workHours" type="text" onkeyup="this.value=this.value.replace(/\\D/g,\'\')" onafterpaste="this.value=this.value.replace(/\\D/g,\'\')" maxlength = 2></td>\n' +
        '                </tr>\n' +
        '            </table>';


    //判断是否是IP地址
    function isIP (str) {
        var reg = /^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/gi;
        if (reg.test(str)) {
            return true;
        } else {
            return false;
        }
    }


    $(function () {
        $('table[name="leixing"]').after(fixed);
        $('table[name="leixing"]').after(elasticity);
        var userId=$.cookie('uid');
        //点点击设置考勤
        $('.divBtn').click(function () {
            $('.return').find('a').attr('href','/attendSet/attendSetting');
            $('table[name="workStart"]').hide();
            $('.newPage').show();
            $('.divTable').hide();
            $('.divBtn').hide();
            $('.saveBtn').attr('btnType','0');
            var isfixed=$('table[name="fixed"]').attr("name");
            if (isfixed===undefined){
                $('table[name="leixing"]').after(fixed);
                $('table[name="leixing"]').after(elasticity);
                $('table[name="workStart"]').hide()
            }
        })

        $('.backBtn').click(function () {
            $('.newPage').hide();
            $('.divTable').show();
            $('.divBtn').show();
            $('#form1')[0].reset();
        })
        dataInit($('#trList'));

        var attendOne=$('input[name="atime1Setother"]:checked').val();
        var attendTwo=$('input[name="atime2Setother"]:checked').val();
        var attendThr=$('input[name="atime3Setother"]:checked').val();
        var attendFour=$('input[name="atime4Setother"]:checked').val();
        var attendFiv=$('input[name="atime5Setother"]:checked').val();
        var attendSix=$('input[name="atime6Setother"]:checked').val();

        /*点击事件*/
        $("input[name='attendType']").click(function(){
            var val=$('input:radio[name="attendType"]:checked').val();
            if(val===0 || val==='0'){
                $('.officeHours').show()
                $('table[name="workStart"]').hide()
                $('table[name="fixed"]').show()
//                $('table[name="workStart"]').replaceWith(fixed);
            }else{
                $('.officeHours').hide()
                $('table[name="workStart"]').show()
                $('table[name="fixed"]').hide()
//                $('table[name="fixed"]').replaceWith(elasticity);
            }
        });

        /*点击事件*/
        $("input[name='ipOn']").click(function(){
            var val=$('input:radio[name="ipOn"]:checked').val();
            if(val===0 || val==='0'){ //关闭
                $('tr[name="wifiOnName"]').hide();
            }else{
                $('tr[name="wifiOnName"]').show();
            }
            $('#ipParagraph1').val('');
            $('#ipParagraph2').val('');
        });


        $('.saveBtn').click(function () {
            var title=$('input[name="title"]').val();
            if (title===''){
                $.layerMsg({content:"类型名称不能为空",icon:2});
                return false;
            }

            var btnType=$(this).attr('btnType');
            var inputVal=''
            $('.workDay:checked').each(function () {
                inputVal+=$(this).val()+',';
            })
            var data;
            var tipText='';
            var errorText='';
            var ipParagraph1 = $('#ipParagraph1').val();
            var ipParagraph2 = $('#ipParagraph2').val();
            var ip=""
            if($('[name="wifiOnName"]').css('display')!='none'){
                if(!isIP(ipParagraph1)){
                    alert("ip地址格式错误")
                    $('#ipParagraph1').focus();
                    return;
                }
                if(!isIP(ipParagraph2)){
                    alert("ip地址格式错误")
                    $('#ipParagraph2').focus();
                    return;
                }
                ip=ipParagraph1+"-"+ipParagraph2;
            }
            if(btnType == '0'){
                $('#form1').attr('action','/attendSet/newAttendSet');
                tipText='新建成功！';
                errorText='新建失败！';
                data={
                    workdate:inputVal,
                    uid:userId,
                    wifiAddr:'',
                    wifiName:'',
                    ipParagraph:ip
                }
            }else {
                $('#form1').attr('action','/attendSet/updateAttendSet');
                tipText='修改成功！';
                errorText='修改失败！';
                var sId=$('.saveBtn').attr('sid')
                data={
                    sid:sId,
                    workdate:inputVal,
                    uid:userId,
                    wifiAddr:'',
                    wifiName:'',
                    ipParagraph:ip
                }
            }
            $('#form1').ajaxSubmit({
                type: 'post',
                dataType: 'json',
                data:data,
                success: function(res) {
                    if(res.flag){
                        $.layerMsg({content:tipText,icon:1});
                        dataInit($('#trList'));
                        $('.newPage').hide();
                        $('.divTable').show();
                        $('.divBtn').show();
                        $('#form1')[0].reset();
//                        $('table[name="fixed"]').remove();
//                        $('table[name="workStart"]').remove();
                    }else {
                        $.layerMsg({content:res.msg,icon:2});
                    }
                }
            })



        });

//        编辑
        $('#trList').on('click','.editData',function () {
            $('.return').find('a').attr('href','/attendSet/attendSetting');

            $('.saveBtn').attr('btnType','1')
            $('.newPage').show();
            $('.divTable').hide();
            $('.divBtn').hide();
            var hoId=$(this).parents('tr').attr('data-id');
            $('.saveBtn').attr('sid',hoId);
            $.ajax({
                type:'get',
                url:'/attendSet/queryAttendSetId',
                dataType:'json',
                data:{sid:hoId},
                success:function (res) {
                    var datas=res.object;
                    if(datas.attendType==='1'){
                        $('.officeHours').hide()
                        $('table[name="fixed"]').hide();
                        $('table[name="workStart"]').show()
                    }else{
                        $('.officeHours').show()
                        $('table[name="fixed"]').show();
                        $('table[name="workStart"]').hide();
                    }
                    $('input[name="attendType"][value="'+datas.attendType+'"]').prop("checked",true);
                    $('input[name="title"]').val(datas.title);
                    $('input[name="commute1"][value="'+datas.commute1+'"]').prop("checked",true);
                    $('input[name="commute2"][value="'+datas.commute2+'"]').prop("checked",true);
                    $('input[name="commute3"][value="'+datas.commute3+'"]').prop("checked",true);
                    $('input[name="commute4"][value="'+datas.commute4+'"]').prop("checked",true);
                    $('input[name="commute5"][value="'+datas.commute5+'"]').prop("checked",true);
                    $('input[name="commute6"][value="'+datas.commute6+'"]').prop("checked",true);
                    $('input[name="atime1Setother"][value="'+datas.atime1Setother+'"]').prop("checked",true);
                    $('input[name="atime2Setother"][value="'+datas.atime2Setother+'"]').prop("checked",true);
                    $('input[name="atime3Setother"][value="'+datas.atime3Setother+'"]').prop("checked",true);
                    $('input[name="atime4Setother"][value="'+datas.atime4Setother+'"]').prop("checked",true);
                    $('input[name="atime5Setother"][value="'+datas.atime5Setother+'"]').prop("checked",true);
                    $('input[name="atime6Setother"][value="'+datas.atime6Setother+'"]').prop("checked",true);
                    $('input[name="atime1"]').val(datas.atime1);
                    $('input[name="atime2"]').val(datas.atime2);
                    $('input[name="atime3"]').val(datas.atime3);
                    $('input[name="atime4"]').val(datas.atime4);
                    $('input[name="atime5"]').val(datas.atime5);
                    $('input[name="atime6"]').val(datas.atime6);
                    $('input[name="worktimeF"]').val(datas.worktimeF);
                    $('input[name="worktimeB"]').val(datas.worktimeB);
                    $('input[name="workafterF"]').val(datas.workafterF);
                    $('input[name="workafterB"]').val(datas.workafterB);
                    $('input[name="workStart"]').val(datas.workStart);
                    $('input[name="workEnd"]').val(datas.workEnd);
                    $('input[name="workHours"]').val(datas.workHours);
                    $('input[name="ipOn"][value="'+datas.ipOn+'"]').prop("checked",true);
                    $('#ipParagraph1').val(datas.ipParagraph.split("-")[0]);
                    $('#ipParagraph2').val(datas.ipParagraph.split("-")[1]);
                    $('input[name="locationOn"][value="'+datas.locationOn+'"]').prop("checked",true);
                    $('input[name="location"]').val(datas.location);
                    $('#ranges').val(datas.ranges);
                    $('input[name="wifiOn"][value="'+datas.wifiOn+'"]').prop("checked",true);
                    $('input[name="isOut"][value="'+datas.isOut+'"]').prop("checked",true);
                    $('input[name="isOvertime"][value="'+datas.isOvertime+'"]').prop("checked",true);
                    $('input[name="isDuty"][value="'+datas.isDuty+'"]').prop("checked",true);

                    $('input[name="isTrip"][value="'+datas.isTrip+'"]').prop("checked",true);
                    $('input[name="isLeave"][value="'+datas.isLeave+'"]').prop("checked",true);
                    $('input[name="isGo"][value="'+datas.isGo+'"]').prop("checked",true);

                    var arr=datas.workdate.split(',');
//                    console.log(arr);
                    for(var i=0;i<arr.length;i++){
                        $('input.workDay[value="'+arr[i]+'"]').prop("checked",true);
                    }
                    if(datas.ipOn==1){
                        $('[name="wifiOnName"]').show()
                    }
                }
            })
        })

        //        删除
        $('#trList').on('click','.deleteData',function () {
            var hoId=$(this).parents('tr').attr('data-id');
            layer.confirm('确定要删除吗？', {
                btn: ['确定','取消'] //按钮
            }, function(index){
                $.ajax({
                    type:'post',
                    url:'/attendSet/delAttendSetbyId',
                    dataType:'json',
                    data:{sid:hoId},
                    success:function (res) {
                        if(res.flag){
                            layer.msg('删除成功！', {icon: 1,time:1000});
                            layer.close(index);
                            dataInit($('#trList'));
                        }else{
                            layer.msg('删除失败！', {icon: 2,time:1000});
                            layer.close(index);
                        }
                    }
                })
            }, function(index){
                layer.closeAll();
            });
        })

//        点击位置
        $('#inLocation').click(function () {
            window.open('/attendSet/attendMap');
        })

        //    点击坐标定位
        $('.dwbtn').click(function () {
            // window.open('/street/chooseMap')
            window.open('/street/mapCoordinates?type=4')
        })

    })
    //  设置坐标
    function setZuobiao(str){
        $('input[name="gridLocation"]').val(str)
    }

    function dataInit(element) {
        $.ajax({
            type:'get',
            url:'/attendSet/selsectAttendSet',
            dataType:'json',
            success:function (res) {
                var datas=res.obj;
                var str='';
                if(res.flag){
                    for(var i=0;i<datas.length;i++){
                        str+='<tr data-id="'+datas[i].sid+'">' +
                            '<td>'+datas[i].title+'</td>' +
//                            '<td>'+datas[i].atime1+'</td>' +
//                            '<td>'+datas[i].atime2+'</td>' +
//                            '<td>'+datas[i].atime3+'</td>' +
//                            '<td>'+datas[i].atime4+'</td>' +
//                            '<td>'+datas[i].atime5+'</td>' +
//                            '<td>'+datas[i].atime6+'</td>' +
                            "<td><div class='publishtip'  totypename="+function () {
                               if(datas[i].attendType=='0'){
                                   var str='';
                                   if(datas[i].atime1Set.split('|')[0]==1&&datas[i].atime1Set.split('|')[1]==1){
                                       str+='上班'+datas[i].atime1+'-'
                                   }
                                   if(datas[i].atime2Set.split('|')[0]==1&&datas[i].atime2Set.split('|')[1]==2){
                                       str+='下班'+datas[i].atime2+'-'
                                   }
                                   if(datas[i].atime3Set.split('|')[0]==1&&datas[i].atime3Set.split('|')[1]==1){
                                       str+='上班'+datas[i].atime3+'-'
                                   }
                                   if(datas[i].atime4Set.split('|')[0]==1&&datas[i].atime4Set.split('|')[1]==2){
                                       str+='下班'+datas[i].atime4+'-'
                                   }
                                   if(datas[i].atime5Set.split('|')[0]==1&&datas[i].atime5Set.split('|')[1]==1){
                                       str+='上班'+datas[i].atime5+'-'
                                   }
                                   if(datas[i].atime6Set.split('|')[0]==1&&datas[i].atime6Set.split('|')[1]==2){
                                       str+='下班'+datas[i].atime6+'-'
                                   }
                                   return str
                               }else if(datas[i].attendType=='1'){
                                   return '签到时间：'+datas[i].workStart+'-最小工时：'+datas[i].workHours+'-签到结束：'+datas[i].workEnd+''
                               }
                            }()+">"+function () {
                                if(datas[i].attendType == '1'){
                                    return '弹性工时';
                                }else {
                                    return '固定签到';
                                }
                            }()+"</div></td>"+//签到类型
                            +'</td>' +
                            '<td>'+function () {
                                if(datas[i].locationOn == '1'){
                                    return '开启';
                                }else {
                                    return '关闭';
                                }
                            }()+'</td>' +
                            +'</td>' +
                            '<td>'+function () {
                                if(datas[i].ipOn == '1'){
                                    return '开启';
                                }else {
                                    return '关闭';
                                }
                            }()+'</td>' +
                            '<td>'+function () {
                                if(datas[i].wifiOn == '1'){
                                    return '开启';
                                }else{
                                    return '关闭';
                                }
                            }()+'</td>' +
                            '<td>'+function () {
                                if(datas[i].isOut == '1'){
                                    return '开启';
                                }else {
                                    return '关闭';
                                }
                            }()+'</td>' +
                            '<td style="width: 90px;"><a href="javascript:;" style="margin-right: 10px;" class="editData">编辑</a>'+function(){
                                if(datas[i].sid == 99){
                                    return ""
                                }else{
                                    return '<a style="color: crimson" href="javascript:;" class="deleteData">删除</a>'
                                }
                            }()+'</td>' +
                            '</tr>'
                    }
                    element.html(str)
                    $('.publishtip').mouseenter(function () {
                        var that = $(this);
                        var str=that.attr('toTypeName').replace(/-/g,'<br>')
                        layer.tips(str,that, {
                            tips: [1, '#3595CC'],
                            time: 10000
                        });
                    })
                    $('.publishtip').mouseleave(function () {
                        layer.closeAll();
                    });
                }
            }
        })

    }

</script>
</body>
</html>
